
#include <boost/asio/buffer.hpp>
#include <boost/asio/connect.hpp>
#include <cstddef>
#include <cstdlib>
#include <iostream>
#include <boost/asio.hpp>
#include <string>

using boost::asio::ip::tcp;



//int send_get_request(tcp::socket s, std::string content);
//int receive_response(tcp::socket s, std::string mbuf);




//int send_get_request(tcp::socket s, std::string content)
//{
	
	//int send_size = 0;
	//if((send_size = s.send(content)) != content.size()) {
			//std::cout<<"sent size don't equal the given content"<<std::endl;
	//}
	//return send_size;

//}


//int receive_response(tcp::socket s, std::string buf) {

	//int receive_size = 0;
	//receive_size = boost::asio::read_until(s, boost::asio::dynamic_buffer(buf), "\n\n");	

	//if (receive_size == 0) {
		//std::cout<<"receive zero data"<<std::endl;
		
	//}
	//return receive_size;

//}



int main() {
		boost::asio::io_context io;

		tcp::resolver rs(io);
		tcp::socket s(io);
		//tcp::resolver::query query("baid.com", "https");
		std::string ip = "192.168.1.100";
		tcp::resolver::results_type ep = rs.resolve(ip.c_str(),"80");
		boost::asio::connect(s, ep);

		std::string request = R"(
			get /home.php HTTP/1.1
			Accept: text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.9
			Accept-Encoding: gzip, deflate
			Accept-Language: zh-CN,zh;q=0.9

			bIn=1
		)";

		if(s.send(request) != request.size()) {
				std::cout<<"send request fail"<<std::endl;
				exit(-1);
		}
		s.receive(boost::asio::buffer(request, 1024));
		std::cout<<request<<std::endl;
	return 0;
}




		
